package com.cjk.controller;

import com.cjk.pojo.Result;
import com.cjk.utils.AliyunOSSOperator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RestController
public class UploadController {

    @Autowired
    private AliyunOSSOperator aliyunOSSOperator;

    /**
     * 上传文件
     * @param file
     * @return
     */
    @PostMapping("/upload")
    public Result upload(MultipartFile file)throws Exception {
        log.info("文件上传：{} ", file);
        aliyunOSSOperator.upload(file.getBytes(), file.getOriginalFilename());
        return Result.success();
    }
}
